<?php
/**
 * Created by PhpStorm.
 * User: 秋刀鱼
 * Date: 2018/6/14
 * Time: 15:29
 */

namespace backend\controllers;

use Yii;
use yii\web\Controller;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use common\models\LoginForm;
use yii\db\query;
use yii\filters\Cors;
use yii\helpers\ArrayHelper;
use \common\helps\tools;//使用工具类

/**
 * PubController
 */
class PubController extends Controller
{

    public function init()
    {
        $this->enableCsrfValidation = false;
    }

    /**
     * {@inheritdoc}
     */
    public function actions()
    {
        return [
            'error' => [
                'class' => 'yii\web\ErrorAction',
            ],
        ];
    }

    //机构条件晒选
    public function actionLowerlevel(){
        header('Access-Control-Allow-Origin:*');
        $query = new \yii\db\Query();
        $post = Yii::$app->request->post();
        $id = $post['id'];

        //部门
        $depart = $query
            ->select(['ID','departname','org_code','org_type'])
            ->from('ifssc_php.t_s_depart')
            ->where(['ID'=>$id])
            ->one();
        //下级
        $depart_low = $query
            ->select(['ID','departname','org_code','org_type'])
            ->from('ifssc_php.t_s_depart')
            ->where(['org_type' => $depart['org_type']+1])
            ->andWhere(['like','org_code',$depart['org_code']])
            ->all();

        $ajax = tools::ajax_return('0','成功',$depart_low);
        return $ajax;
    }


}